#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project  : test-interface
# @File     : set_case_information.py
# @Author   : LiuLei
# @Time     : 2021/7/17 10:10

from setting import *

def creat_case_information():
    file_lists=os.listdir(DATA_PATH)

    template_file=os.path.join(BASE_PATH,'case_template_ll.txt')

    for f in file_lists:
        if f.endswith('.yaml') or f.endswith('.yml'):

            data_file=f.replace('.yaml','').replace('.yml','')

            test_method_name=data_file.lower()
            test_class_name=test_method_name.capitalize()

            with open(template_file,'r',encoding='utf-8') as temp:
                content=temp.read()%{
                    "class_name":test_class_name,
                    "method_name":test_method_name,
                    "data_file":data_file
                }
            test_case_file="test_%s.py" % data_file

            with open(os.path.join(CASE_PATH,test_case_file),'w',encoding='utf-8') as f:
                f.write(content)
